#coding:utf-8
import requests
from bs4 import BeautifulSoup
import codecs
r = requests.get("http://read.qidian.com/hankread/2465506/6482008")
html_doc  = r.content.decode("utf-8")
f = codecs.open("novel.html",mode = 'w',encoding ="utf-8")
f.write(html_doc)
f.close()
soup = BeautifulSoup(html_doc,"lxml")
chapters = soup.find_all(name = "div",attrs{"class":"main-text-wrap"})
for chapter in chapters:
    content = chapter.text
    f=codecs.open("novel.txt",mode = 'a',encoding = "utf-8")
    f.write(content)
    f.close()
